Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up Prometheus labels scraped from proxy #633

Merged
merged 1 commit into from
Mar 27, 2018
Merged

Conversation

siggy
Copy link
Member

@siggy siggy commented Mar 27, 2018

The Prometheus scrape config collects from Conduit proxies, and maps
Kubernetes labels to Prometheus labels, appending "k8s_".

This change keeps the resultant Prometheus labels consistent with their
source Kubernetes labels. For example: "deployment" and
"pod_template_hash".

Signed-off-by: Andrew Seigner siggy@buoyant.io

The Prometheus scrape config collects from Conduit proxies, and maps
Kubernetes labels to Prometheus labels, appending "k8s_".

This change keeps the resultant Prometheus labels consistent with their
source Kubernetes labels. For example: "deployment" and
"pod_template_hash".

Signed-off-by: Andrew Seigner <siggy@buoyant.io>
@siggy siggy added this to the 0.4.0 milestone Mar 27, 2018
@siggy siggy self-assigned this Mar 27, 2018
@siggy siggy requested review from rmars and adleong March 27, 2018 21:40
@siggy siggy added the review label Mar 27, 2018
Copy link
Member

@adleong adleong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⭐ Non-blocking wiffle-waffling on naming

# special case k8s' "job" label, to not interfere with prometheus' "job"
# label
# __meta_kubernetes_pod_label_conduit_io_proxy_job=foo =>
# k8s_job=foo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been on both sides of the fence on this, but the fact that we have to prefix job to avoid conflicts makes me kinda think we should go back to prefixing all resources for consistency...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree it's unfortunate that k8s_job ends up being a special case. I think in general it will make our code slightly more readable. An example I just ran into:
#627 (comment)
...where we're referring to pod-template-hash when talking to Kubernetes and then k8s_pod_template_hash immediately after when querying Prometheus.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I'll note that Googling around yields a direct k8s->prom label mapping to be pretty standard, and what folks would naturally expect when querying Prometheus for Kubernetes data:
https://github.com/prometheus/prometheus/blob/master/documentation/examples/prometheus-kubernetes.yml#L266-L267

# __meta_kubernetes_pod_label_conduit_io_proxy_deployment=foo =>
# k8s_deployment=foo
# deployment=foo
- action: labelmap
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this action do when replacement is not specified?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

per https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config, replacement defaults to the matched group $1:

[ replacement: <string> | default = $1 ]

Copy link

@rmars rmars left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ 🏷 🔑 lgtm!

@siggy siggy merged commit fe35509 into master Mar 27, 2018
@siggy siggy deleted the siggy/clean-prom-labels branch March 27, 2018 22:01
@siggy siggy removed the review label Mar 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants